package com.baizhi.stringx;

import java.io.UnsupportedEncodingException;

/**
 * String常用方法 6
 */
public class StringDemo07 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "我爱Java";

        byte[] bytes = str.getBytes(); //根据系统默认的字符集转换成二进制数组

        byte[] gbks = str.getBytes("UTF-8"); //按照指定的字符集将字符串转换成二进制数组
    }
}
